import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param str string字符串 
     * @return string字符串ArrayList
     */
     public void recursion(char[] charStr,ArrayList<String> res,StringBuffer temp,Boolean[] vis){
        if(temp.length()==charStr.length){
            res.add(new String(temp));
            return;
        }
        for(int i=0;i<charStr.length;i++){
     if(vis[i]==true || i>0&&vis[i-1]&&charStr[i]==charStr[i-1]){
        continue;
     }
     temp.append(charStr[i]);
     vis[i]=true;
     recursion(charStr,res,temp,vis);
     temp.deleteCharAt(temp.length()-1);
vis[i]=false;
        }
     }
    public ArrayList<String> Permutation (String str) {
        // write code here
        char[] charStr=str.toCharArray();
        Arrays.sort(charStr);
        ArrayList<String> res=new ArrayList<String>();
        StringBuffer temp=new StringBuffer();
        Boolean[] vis =new Boolean[str.length()];
        Arrays.fill(vis,false);
      recursion(charStr,res,temp,vis);
      return res;
    }
}